import { exportUrl, downloadTemplateUrl, getWarningStatusList } from "@/api/warning/mesWarningReport"

import { exportExcel } from "@/utils/judge"

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl
    //auth: "auth:operlog:export", //权限字段
  },
  {
    name: $i18n.t("common.add"),
    type: "primary",
    icon: "el-icon-circle-plus-outline",
    handleName: "add" //点击时返回的标识
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    icon: "el-icon-delete",
    handleName: "deleteBatch", //点击时返回的标识
    isMultiple: true // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  },
  // {
  //   name: $i18n.t("common.import"),
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "import" //点击时返回的标识
  // }
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.edit"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "edit" //点击时返回的标识
  },
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail" //点击时返回的标识
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "delete" //点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    warningCode: {
      type: "input",
      label: $i18n.t("mesWarningReport.warningCode")
    },
    warningName: {
      type: "input",
      label: $i18n.t("mesWarningReport.warningName")
    },
    warningType: {
      type: "input",
      label: $i18n.t("mesWarningReport.warningType")
    },
    warningStatus: {
      type: "select",
      label: $i18n.t("mesWarningReport.warningStatus"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getWarningStatusList()
        return list.data.result
      }
    }
  }
}
// 新增/删除表单配置
export const formMixin = {
    data(){
      return {
        formDescDialog:{
          span: 24,
          disabled: false,
          isShowSubmitBtn: true,
          formDesc: {
            warningCode: {
              type: "input",
              label: $i18n.t("mesWarningReport.warningCode"),
              layout: 12,
              required: false
            },
            warningName: {
              type: "input",
              label: $i18n.t("mesWarningReport.warningName"),
              layout: 12,
              required: false
            },
            warningType: {
              type: "input",
              label: $i18n.t("mesWarningReport.warningType"),
              layout: 12,
              required: false
            },
            workshopName: {
              type: "input",
              label: $i18n.t("common.workshopName"),
              layout: 12,
              required: false
            },
            workshopCode: {
              type: "input",
              label: $i18n.t("common.workshopCode"),
              layout: 12,
              required: false
            },
            lineCode: {
              type: "input",
              label: $i18n.t("common.lineCode"),
              layout: 12,
              required: false
            },
            lineName: {
              type: "input",
              label: $i18n.t("common.lineName"),
              layout: 12,
              required: false
            },
            factoryCode: {
              type: "input",
              label: $i18n.t("common.factoryCode"),
              layout: 12,
              required: false
            },
            warningStatus: {
              type: "select",
              label: $i18n.t("mesWarningReport.warningStatus"),
              layout: 12,
              required: false,
              prop: {
                value: "value",
                text: "description"
              },
              options: async (data) => {
                const list = await getWarningStatusList()
                return list.data.result
              }
            },
            beginDate: {
              type: "date",
              label: $i18n.t("mesWarningReport.beginDate"),
              layout: 12,
              required: false,
              attrs: {
                valueFormat: "yyyy-MM-dd"
              },
              on: {
                change: (val)=>{
                  this.handleBeginDate(val)
                },
              },
            },
            endDate: {
              type: "date",
              label: $i18n.t("mesWarningReport.endDate"),
              layout: 12,
              required: false,
              attrs: {
                valueFormat: "yyyy-MM-dd"
              },
              on: {
                change: (val)=>{
                  this.handleEndDate(val)
                },
              }
            },
            remark: {
              type: "input",
              label: $i18n.t("common.remark"),
              layout: 12,
              required: false
            }
          }
        }
      }
    }
}

//导入数据
export const importFormDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    model: {
      type: "button",
      label: "",//$i18n.t("mesWarningReport.model"),
      layout: 24,
      required: false,
      title: $i18n.t("common.downloadTemplate"),
      style: {
        color: "#1867c0",
        fontSize: "14px"
      },
      on: {
        click: () => {
          exportExcel(downloadTemplateUrl)
        }
      }
    },
    file: {
      type: "input",
      label: $i18n.t("common.chooseFile"),
      layout: 24
      // required: true,
    }
  }
}
